package com.itfs;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;

public class CollectionsDemo03Test {
    public static void main(String[] args) {
        Collection<Student> list = new ArrayList<>();
        Student stu1 = new Student("张三", 19);
        Student stu2 = new Student("李四", 18);
        Student stu3 = new Student("王五", 20);
        Student stu4 = new Student("赵六", 19);
        Collections.addAll(list, stu1, stu2, stu3, stu4);

        //迭代器
        Iterator<Student> it = list.iterator();
        while(it.hasNext()){
            Student student = it.next();
            System.out.println("迭代器" + student);
        }


        //for循环
        for (Student student : list) {
            System.out.println("for循环"+ student);
        }

    }



}
